﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace TheOutfield.UmbExt.UniversalMediaPicker.Providers.Screenr
{
    public class ScreenrProvider : AbstractProvider
    {
        private ScreenrConfigControl _configControl;

        public ScreenrProvider()
        { }

        public ScreenrProvider(string config)
            : base(config)
        {
            Service = new ScreenrService(config);
        }

        public override string Alias
        {
            get { return "Screenr"; }
        }

        public ScreenrService Service { get; private set; }

        public override Interfaces.IConfigControl ConfigControl
        {
            get
            {
                if (_configControl == null)
                    _configControl = new ScreenrConfigControl(Config);

                return _configControl;
            }
        }

        public override Interfaces.ICreateControl CreateControl
        {
            get { throw new NotImplementedException(); }
        }

        public override MediaItem GetMediaItemById(string id)
        {
            return Service.GetVideo(id).ToMediaItem();
        }

        public override IList<MediaItem> GetMediaItems(string parentId)
        {
            return Service.GetVideos().Select(video => video.ToMediaItem()).ToList();
        }
    }
}